<template>
	<view class="container">
		<l-file ref="lFile" @up-success="upSuccess"></l-file>
		<view class="top">
			<view class="tdmc u-m-l-30" v-if="model.users && model.users[0]">
				<text>
					<image style="width:32rpx;height:28rpx;margin-right:11rpx;" src="../../../static/img/icon_qy.png" />{{model.users[0].type == 10?"团队":model.users[0].type == 1?"企业":"个人"}}</text>
				<text class="right">{{model.users[0].username || "暂无"}}</text>
			</view>
		</view>

		<view :hidden="userFeedbackHidden" class="popup_content">
			<view class="popup_title">进度名称</view>
			<view class="popup_textarea_item">
				<textarea class="popup_textarea" placeholder='请输入进度名称' v-model="feedbackContent">
				</textarea>
				<view @click="submitFeedback()">
					<button class="popup_button">提交</button>
				</view>
			</view>
		</view>
		<view class="popup_overlay" :hidden="userFeedbackHidden" @click="hideDiv()"></view>

		<u-gap :bg-color="bgColor" :height="height"></u-gap>
		<view class="u-m-t-30 u-m-l-10 u-m-r-10 ">
			<view class="u-flex u-row-between tdcy" @click="selectShow(0)">
				<view class="u-font-30 u-m-l-30" style="font-weight: bold;">
					N+1成员
				</view>
				<view class="u-flex u-row-center u-m-r-30" style="margin-left: auto;">
					<text class="u-font-30" style="color: #AB61FF;" v-if="model.users != undefined">{{model.users.length}}个</text>
				</view>
				<u-icon name="arrow-down" style="margin-right: 20upx;" @click="selectShow(0,true)" v-if="!flagList[0]"></u-icon>
				<u-icon name="arrow-up" style="margin-right: 20upx;" @click="selectShow(0,false)" v-if="flagList[0]"></u-icon>
			</view>
			<u-read-more :toggle="toggle" :show-height="showHeight" ref="uReadMore" closeText="收起" open-text="查看全部">
				<view v-for="(item, index) in model.users"
					:key="index">
				<view
					class="f-list u-row-between u-border-bottom u-flex u-m-r-20 u-m-l-20 u-p-t-20 u-p-b-20"
					
					v-show="flagList[0]"
					@click="showChildren(index)"
				>
					<block v-if="item.id != $store.state.userInfo.id">
						<view class="u-flex">
							<view class="qylg" :style="{ backgroundImage: 'url(' + logoMask + ')' }">
								<text class="u-line-2">{{ item.username }}</text>
							</view>
							<view class="f-item u-m-l-32">
								<view class="title u-flex u-row-between">
									<view class="">
										<text class="name">{{ item.username }}</text>
										<text v-if="item.leader" class="tz">团长</text>
										<text v-if="item.type == 10" class="td">团队</text>
									</view>
									<view class="bzj" v-if="item.bond">
										<text>￥{{ item.bond }}</text>
									</view>
								</view>
								<view class="explain" v-if="item.bond === null">未交保证金</view>
								<view class="explain" v-if="item.type == 10 && item.children.length">团队成员{{item.children.length}}人</view>
								
							</view>
						</view>
						<u-icon name="arrow-down" style="margin-right: 20upx;" v-if="item.type == 10 && !item.show"></u-icon>
						<u-icon name="arrow-up" style="margin-right: 20upx;"  v-if="item.type == 10 && item.show"></u-icon>
					</block>
					<block v-else>
						<view class="u-flex">
							<view class="qylg" :style="{ backgroundImage: 'url(' + logoMask + ')' }">
								<text class="u-line-2">{{ item.username }}</text>
							</view>
							<view class="f-item u-m-l-32">
								<view class="title u-flex-col">
									<view class="">
										<text class="name">{{ item.username }}</text>
										<text v-if="item.leader" class="tz">团长</text>
										
									</view>
									<view class="explain" v-if="item.bond === null">未交保证金</view>
								</view>
							</view>
						</view>
						<view class="scxy u-flex u-row-center" v-if="!item.bond && model.demand && model.demand.integrityDeposit" @click="pay">缴纳保证金</view>
					</block>
					</view>
					<view class="u-p-20 team-bg" v-if="item.show && item.children && item.children.length">
						<view
							class="f-list u-row-between u-border-bottom u-flex u-m-r-20 u-m-l-20 u-p-t-20 u-p-b-20" v-for="(v, t) in item.children" :key="'c' + t">
						<view  class="u-flex">
							<view class="qylg" :style="{ backgroundImage: 'url(' + logoMask + ')' }">
								<text class="u-line-2">{{ v.name }}</text>
							</view>
							<view class="f-item u-m-l-32">
								<view class="title u-flex-col">
									<view class="">
										<text class="name">{{ v.name }}</text>
										<text v-if="v.leader" class="tz">团长</text>
									</view>
									<view class="explain" v-if="v.bond === null">未交保证金</view>
								</view>
							</view>
						</view>
						<view class="scxy u-flex u-row-center" v-if="v.id == $store.state.userInfo.id && !v.bond && model.demand && model.demand.integrityDeposit" @click="pay">缴纳保证金</view>
						</view>
					</view>
				</view>
			</u-read-more>
			
		</view>
		<u-gap :bg-color="bgColor" :height="height" :margin-top="marginTop" :margin-bottom="marginBottom"></u-gap>
		<view class="middle-tdxy">
			<view class=" u-flex u-row-between u-m-l-30" @click="selectShow(1)">
				<view class="u-font-30 xmfp">合同签订</view>
				<view class="u-flex u-col-center">
					<view v-show="show"  @click="onUpload(true)" class="scxy" style="margin-right: 30upx;">
						<image style="" src="../../../static/img/jh.png" mode=""></image>
						<text>上传协议</text>
					</view>
					<u-icon name="arrow-down" style="margin-right: 20upx;" @click="selectShow(1,true)" v-if="!flagList[1]"></u-icon>
					<u-icon name="arrow-up" style="margin-right: 20upx;" @click="selectShow(1,false)" v-if="flagList[1]"></u-icon>
				</view>
			</view>
			<view v-for="(item,index) in model.fileAgrees" :key="index" class="tdxy u-m-l-30 u-m-t-30" @click="loadFile(item.path)"
			 v-if="flagList[1]">
				<view class="word u-m-l-30 u-m-r-30 u-p-t-30">
					<image src="../../../static/img/word.png" mode=""></image>
					<text class="u-line-1">{{item.oldName}}</text>
				</view>
				<view class="sctime u-flex u-row-between u-m-l-30 u-m-r-30 u-p-t-30">
					<view class="u-flex">
					<text class="scsj">上传时间:</text>
					<text class="sctime">{{item.uploadTime}}</text>
					</view>
					<view v-if="$store.state.userInfo.id == item.userId" @click="delFile(item.id)">
						删除
					</view>
				</view>
			</view>
		</view>
		<u-gap :bg-color="bgColor" :height="height" :margin-top="marginTop" :margin-bottom="marginBottom"></u-gap>
		<view class="middle-hyjy  u-m-t-30">
			<view class=" u-flex u-row-between u-m-l-30 " @click="selectShow(2)">
				<view class="u-font-30 xmfp">会议纪要</view>
				<view class="u-flex u-col-center">
					<view v-show="show"  @click="tonewSummary(id)" class="scxy" style="margin-right: 30upx;">
						<image style="" src="../../../static/img/jh.png" mode=""></image>
						<text>新增纪要</text>
					</view>
					<u-icon name="arrow-down" style="margin-right: 20upx;" @click="selectShow(2,true)" v-if="!flagList[2]"></u-icon>
					<u-icon name="arrow-up" style="margin-right: 20upx;" @click="selectShow(2,false)" v-if="flagList[2]"></u-icon>
				</view>

			</view>
			<view class="xhx" v-show="flagList[2]">
			</view>
			<view class="uni-padding-wrap uni-common-mt" v-show="flagList[2]">
				<swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
					<swiper-item  v-for="(item,index) in model.notepadRecords" :key="index">
						<view class="u-m-l-30">
							<view class="u-flex u-m-t-35">
								<view class="ty">
								</view>
								<text class="xmjz">{{item.title}}</text>
								<text class="sctime" v-if="item.createTime != undefined">{{item.createTime.substr(0,10)}}</text>
							</view>
							<view class="u-flex">
								<view class="xx">
									
								</view>
								<view style="width: 100%;">
									<view class="zxjz u-m-t-15  u-m-b-15">
										{{item.content}}
									</view>
									<view class="u-flex" v-if="item.imgUrl != undefined">
										<view class="tp" v-for="(xitem,xindex) in item.imgUrl.split(',')" :key="xindex">
											<image @tap="previewImageStr(xindex,item.imgUrl)" :src="getImgUrl(xitem)" style="width: 100%;height: 100%;"></image>
										</view>
									</view>
									<view class="u-m-l-30 u-m-t-20 u-flex u-row-between u-col-center">
										<view class="u-flex u-col-center">
										<view class="tyqk">
											团员确认情况
										</view>
										<view class="hekuai" v-if="item.read != null">
											{{item.read.length}}/{{item.read.length+item.unread.length}}
										</view>
										<view class="hekuai" v-else>0/0</view>
										<view class="u-m-l-30" v-if="$store.state.userInfo.id == item.createUserId" @click="delSummary(item.id)">删除</view>
										</view>
										<view class="u-m-r-30">
											<image @click="toConfirmation(item)" class="sd" src="../../../static/img/sd.png" mode=""></image>
										</view>
									</view>
								</view>
							</view>
							
						</view>
					</swiper-item>
				</swiper>
				
			</view>
		</view>
		<u-gap :bg-color="bgColor" :height="height" :margin-top="marginTop" :margin-bottom="marginBottom"></u-gap>
		<view class="middle-hyjy">
			<view class="u-flex u-row-between u-p-l-30 u-m-b-30 " @click="selectShow(3)">
				<view class="u-font-30 xmfp">进度查询</view>
				<view class="u-flex u-col-center">
					<view v-show="show"   @click="xzjd" class="scxy" style="margin-right: 30upx;">
						<image style="" src="../../../static/img/jh.png" mode=""></image>
						<text>新增进度</text>
					</view>
					<u-icon name="arrow-down" style="margin-right: 20upx;" @click="selectShow(3,true)" v-if="!flagList[3]"></u-icon>
					<u-icon name="arrow-up" style="margin-right: 20upx;" @click="selectShow(3,false)" v-if="flagList[3]"></u-icon>
				</view>
			</view>
			<view class="u-m-30 u-p-l-30" v-if="flagList[3]">

				<u-time-line>
					<u-time-line-item v-for="(item,index) in model.progress" :key="index" nodeTop="2" class="u-p-b-30">
						<template v-slot:node>
							<view class="u-node">
								<image src="../../../static/img/icon_jd.png" style="height: 52rpx;width: 52rpx;" />
							</view>
						</template>
						<template v-slot:content>
							<view>
								<view class="u-order-title u-p-b-20">{{item.name}}</view>
								<view class="u-flex">
								<view class="u-order-time">{{item.createTime}}</view>
								<view class="u-m-l-30" v-if="$store.state.userInfo.id == item.createUserId" @click="delSchedule(item.id)">删除</view>
								</view>
							</view>
						</template>
					</u-time-line-item>
					<!-- <u-time-line-item nodeTop="2">
					<template v-slot:node>
						<view class="u-node">
							<image src="../../../static/img/icon_jd.png" style="height: 52rpx;width: 52rpx;" />
						</view>
					</template>
					<template v-slot:content>
						<view>
							<view class="u-order-title u-p-b-20">材料进场</view>	
							<view class="u-order-time">2020-06-01  16:24:18</view>
						</view>
					</template>
				</u-time-line-item> -->
				</u-time-line>
			</view>

		</view>
		<u-gap :bg-color="bgColor" :height="height" :margin-top="marginTop" :margin-bottom="marginBottom"></u-gap>
		<view class="u-m-t-30 ">
			<view class="u-flex u-row-between u-p-l-30 " style="width:100%" @click="selectShow(4)">
				<view class="u-font-30" style="font-weight: bold;">
					项目列表
				</view>
				<u-icon name="arrow-down" style="margin-right: 20upx;" @click="selectShow(4,true)" v-if="!flagList[4]"></u-icon>
				<u-icon name="arrow-up" style="margin-right: 20upx;" @click="selectShow(4,false)" v-if="flagList[4]"></u-icon>
			</view>
			<view class="xmlb u-m-30 u-m-t-30 u-p-b-30" v-if="flagList[4]">
				<view class="u-m-b-20 u-p-b-10" style="background: #F5F5F9;" v-for="(p,index) in model.projects" :key="p.id">
					<view class="u-flex u-row-between u-p-30 u-border-bottom">
						<view class="tubiao u-flex">
							{{p.name}}
						</view>
						<!-- <view class="">
							<image style="width: 48rpx; height: 48rpx;" src="../../../static/register/xy.png" mode=""></image>
						</view> -->
					</view>
					<view class="u-p-b-20">
						<view class="u-flex u-m-t-30 u-m-l-28 u-font-30">
							<text class="hz">合同金额</text>
							<text class="js" v-if="p.demand">{{p.demand.sjfy}}元</text>
						</view>
						<view class="u-flex u-m-t-30 u-m-l-28 u-font-30">
							<text class="hz">项目地点</text>
							<text class="js" v-if="p.demand">{{p.demand.region}}</text>
						</view>
						<view class="u-flex u-m-t-30 u-m-l-28 u-font-30">
							<text class="hz">甲方</text>
							<text class="js">{{p.userName}}</text>
						</view>
						<view class="u-m-t-30 u-m-l-28 u-font-30">
							<text class="hz">乙方</text>
							<view class="u-flex u-p-r-20" style="flex-wrap: wrap;">
								<view class="qylg-p" v-for="(v,i) in p.secondParty" :key="'s'+i" :style="{ backgroundImage: 'url(' + logoMask + ')' }" v-if="i > 0">
									<text class="u-line-2">{{ v.name }}</text>
								</view>
							</view>
						</view>
					</view>
				</view>

			</view>

		</view>
		<u-gap :bg-color="bgColor" :height="height" :margin-top="marginTop" :margin-bottom="marginBottom"></u-gap>
		<view class="middle-hyjy">
			<view class="u-flex u-row-between u-p-l-30" style="width:100%" @click="selectShow(5)">
				<view class="u-font-30 xmfp">考核课程</view>
				<view class="u-flex u-row-between">
					<view v-show="show"  @click="toChoice(id)" class="scxy u-flex u-col-center u-m-r-30">
						<image style="" src="../../../static/img/jh.png" mode=""></image>
						<text>课程选择</text>
					</view>
					<u-icon name="arrow-down" style="margin-right: 20upx;" @click="selectShow(5,true)" v-if="!flagList[5]"></u-icon>
					<u-icon name="arrow-up" style="margin-right: 20upx;" @click="selectShow(5,false)" v-if="flagList[5]"></u-icon>
				</view>
			</view>
			<view class="u-p-t-20" v-if="flagList[5]">
				<block v-for="(item,index) in courses" :key="item.id">
					<u-swipe-action :show="item.show" :index="index" 
							v-if="$store.state.userInfo.id != item.selectCourseUserId"
							@click="delCourse" @open="open"
							:options="options"
							style="width: 100%;"
							class="u-p-t-20"
						>
							<view class="u-p-20" style="width:90%;margin:0 auto 20rpx auto;background: #F5F5F9;" @click="toCourse(item.id)">
								<view class="u-flex u-p-b-10">
									<view style="width: 200rpx;">
										<image src="../../../static/img/icon_kc.png" style="width:25rpx;height: 26rpx;margin-right:15rpx;" />
										<text>课程名称</text>
									</view>
									<view style="flex:1;display: flex;justify-content: space-between;align-items: center;">
										<text>{{item.name}}</text>
										<image src="../../../static/img/more_gray.png" style="width: 48rpx;height:48rpx;" />
									</view>
								</view>
								<view class="u-flex">
									<view style="width: 200rpx;">
										<image src="../../../static/img/icon_ds.png" style="width:25rpx;height: 26rpx;margin-right:15rpx;" />
										<text>导师名称</text>
									</view>
									<text>{{item.teacherName}}</text>
									<image src="../../../static/img/more_gray.png" style="width: 48rpx;height:48rpx;visibility: hidden;" />
								</view>
							</view>
						</u-swipe-action>
						<view v-else class="u-p-20" style="width:90%;margin:0 auto 20rpx auto;background: #F5F5F9;" @click="toCourse(item.id)">
							<view class="u-flex u-p-b-10">
								<view style="width: 200rpx;">
									<image src="../../../static/img/icon_kc.png" style="width:25rpx;height: 26rpx;margin-right:15rpx;" />
									<text>课程名称</text>
								</view>
								<view style="flex:1;display: flex;justify-content: space-between;align-items: center;">
									<text>{{item.name}}</text>
									<image src="../../../static/img/more_gray.png" style="width: 48rpx;height:48rpx;" />
								</view>
							</view>
							<view class="u-flex">
								<view style="width: 200rpx;">
									<image src="../../../static/img/icon_ds.png" style="width:25rpx;height: 26rpx;margin-right:15rpx;" />
									<text>导师名称</text>
								</view>
								<text>{{item.teacherName}}</text>
								<image src="../../../static/img/more_gray.png" style="width: 48rpx;height:48rpx;visibility: hidden;" />
							</view>
						</view>
				</block>
			</view>
		</view>
		<u-gap :bg-color="bgColor" :height="height" :margin-top="marginTop" :margin-bottom="marginBottom"></u-gap>

		<view class="u-m-l-30 u-m-t-30">
			<view class="u-flex u-row-between u-p-b-30 tdcy" @click="selectShow(6)">
				<view class="u-font-30" style="font-weight: bold;">
					文件
				</view>
				<view class="u-flex u-col-center">
					<view v-show="show" class="sc" style="margin-right: 30upx;">
						<image style="" src="../../../static/img/jh.png" mode=""></image>
						<text @click="onUpload(false)">上传</text>
					</view>
					<u-icon name="arrow-down" style="margin-right: 20upx;" @click="selectShow(6,true)" v-if="!flagList[6]"></u-icon>
					<u-icon name="arrow-up" style="margin-right: 20upx;" @click="selectShow(6,false)" v-if="flagList[6]"></u-icon>
				</view>
			</view>
		</view>
		<view class="u-p-b-20" v-if="flagList[6]">
			<block v-for="(item,index) in model.files" :key="item.id">
			<u-swipe-action :show="item.show" :index="index" 
					v-if="$store.state.userInfo.id == item.userId"
					@click="delFiles" @open="openFiles"
					:options="options"
					style="width: 100%;"
				>
				<view class="f-list u-flex u-p-t-20 u-p-b-20 u-col-center" style="display: flex;justify-content: space-between;">
					<view class="qylg">
						<image style="width: 64rpx; height: 64rpx;margin-top:20rpx;" src="../../../static/img/file.png" mode=""></image>
					</view>
					<view class="f-item" style="flex: 1;" @click="onOpenDoc(item.path)">
						<view class="u-font-34">
							<text style="display:block;width:400rpx;" class="u-line-1">{{item.oldName}}</text>
						</view>
						<view class="title u-flex u-m-t-12" style="width: 80%;">
							<text class="name">{{ item.userName }}</text>
							<view class='u-flex u-row-between' style="width: 100%;">
							<text class="rq">{{item.uploadTime.substr(0,10)}}</text>
							<text class="wjdx">{{item.size/1000+'KB'}}</text>
							</view>
						</view>			
					</view>
					<view class="xz" @click="onDown(item.path)" style="margin-right: 20upx;">
						下载
					</view>
				</view>
				
			</u-swipe-action>
				<view v-else class="f-list u-flex u-p-t-20 u-p-b-20 u-col-center" style="display: flex;justify-content: space-between;">
				<view class="file-img ">
					<image style="width: 64rpx; height: 64rpx;" src="../../../static/img/file.png" mode=""></image>
				</view>
				<view class="f-item " style="flex: 1;" @click="onOpenDoc(item.path)">
					<view class="u-font-34">
						<text style="display:block;width:400rpx;" class="u-line-1">{{item.oldName}}</text>
					</view>
					<view class="title u-flex u-m-t-12" style="width: 80%;">
						<text class="name">{{ item.userName }}</text>
						<view class='u-flex u-row-between' style="width: 100%;">
						<text class="rq">{{item.uploadTime.substr(0,10)}}</text>
						<text class="wjdx">{{item.size/1000+'KB'}}</text>
						</view>
					</view>			
				</view>
				<view class="xz" @click="onDown(item.path)" style="margin-right: 20upx;">
					下载
				</view>
			</view>
			
			
			</block>
		</view>

	</view>
</template>

<script>
import lFile from '@/components/l-file/l-file.vue'
	export default {
		components: {lFile},

		data() {
			return {
				type:2,
				syncCourse: {
					id:'',
					userId:'',
					type:2,
				},
				options: [
					{
						text: '删除',
						style: {
							backgroundColor: '#dd524d'
						}
					}
				],
				logoMask: this.$mAssetsPath.logoMask,
				localPath: '',
				baseUrl:this.$mConfig.baseUrl,
				indicatorDots: true,
				autoplay: false,
				interval: 2000,
				duration: 500,
				flagList: [false, false, false, false, false, false],
				id: 0,
				toggle: false,
				showHeight: 300,
				height: 20,
				bgColor: this.$u.color.bgColor,
				marginTop: 30,
				marginBottom: 30,
				bjxm: "../../static/homepage/xmkk.png",
				list: [],
				userFeedbackHidden: true, // 默认隐藏
				feedbackContent: '', // 用户反馈内容
				model: {
					courses: [],
					notepadProgresss: [],
					nplusone: {},
					fileAgrees: [],
					nplusUsers: [],
					files: [],
					notepadRecords: [],
					companyName:''
				},
				isLeader:false,
				userId:'',
				show:true,
				courses:[]
			}
		},
		onLoad(options) {
			console.log("options",options);
			if (options.id) {
				this.id = options.id;
				this.syncCourse.id = options.id;
			}			
			if(options.userId){
				this.userId = options.userId;
				this.syncCourse.userId = options.userId;
			}
			if(options.teamChatId){
				this.teamChatId = options.teamChatId;
				this.checkLeader();
			}			
			uni.setStorageSync('syncCourse',this.syncCourse)
			console.log("syncCourse",JSON.stringify(this.syncCourse));
		},
		onShow(){
			this.initPage(this.id);
			this.listAddedCourse();
		},
		methods: {	
			isNeedPay(val){
				if(!val) val= 0;
				if(this.model.demand.integrityDeposit){
					let money = parseFloat(this.model.demand.integrityDeposit) - parseFloat(val)
					if(money > 0){
						return true
					}else{
						return false
					}
				}else{
					return false
				}
			},			
			async pay() {
				var payData = { payMoney: this.model.demand.integrityDeposit, type: 1, id: this.id }
				let { data, code } = await this.$apis.createTeamPayBond(payData)
				console.log('createTeamPayBond', data)
				if (code == 200) {
					this.$mRouter.push({
						route: this.$mRoutesConfig.pay,
						query: {
							datas: JSON.stringify(data)
						}
					})
				}
			},
			async needPay(val) {
				var payMoney = this.model.demand.integrityDeposit;
				if(!val) val= 0;
				if(this.model.demand.integrityDeposit){
					payMoney = parseFloat(this.model.demand.integrityDeposit) - parseFloat(val)
				}
				var payData = { payMoney: payMoney, type: 1, id: this.id }
				let { data, code } = await this.$apis.createTeamPayBond(payData)
				console.log('createTeamPayBond', data)
				if (code == 200) {
					this.$mRouter.push({
						route: this.$mRoutesConfig.pay,
						query: {
							datas: JSON.stringify(data)
						}
					})
				}
			},
			async fetchGroupPersonBond(reqBody, index) {
				console.log('index', index)
				let { data } = await this.$apis.fetchGroupPersonBond(reqBody)
				let users = this.model.users[index] ? this.model.users[index] : []
				users.children = data
				users.show = !users.show
				this.model.users[index] = users
			
				console.log(this.model.users)
				this.$forceUpdate()
			},
			showChildren(index) {
				let users = this.model.users
				if (users && users[index] && users[index].type == 10) {
					var fromTeamId = users[index].fromTeamId.split('_')
					console.log('fromTeamId', fromTeamId)
					if (fromTeamId.length && fromTeamId[1] > 0) {
						let reqBody = {
							id: fromTeamId[1],
							type: 1
						}
						this.fetchGroupPersonBond(reqBody, index)
					}
				}
			},	
			delSchedule(id){
				var that = this;
				uni.showModal({
					content:"删除该进度",
					success(res) {
						if(res.confirm) that.deleteNplusoneProgress(id);
					}
				})
			},
			async deleteNplusoneProgress(id){
				let {code} = await this.$apis.deleteNplusoneProgress({id:id});
				if(code == 200){
					this.initPage(this.id);
				}
			},
			delCourse(id){
				var that = this;
				uni.showModal({
					content:"删除该课程",
					success(res) {
						if(res.confirm) that.deleteUserCourse(id);
					}
				})
			},
			async deleteUserCourse(index) {
				let {code} = await this.$apis.deleteUserCourse({id:this.courses[index].selectDataId});
				if(code == 200){
					this.courses.splice(index, 1);	
				}
			},
			// 如果打开一个的时候，不需要关闭其他，则无需实现本方法
			open(index) {
				console.log("open",index)
				// 先将正在被操作的swipeAction标记为打开状态，否则由于props的特性限制，
				// 原本为'false'，再次设置为'false'会无效
				this.courses[index].show = true;
				this.courses.map((val, idx) => {
					if(index != idx) this.courses[idx].show = false;
				})
			},	
			delFiles(index){
				var that = this;
				uni.showModal({
					content:"删除该文件",
					success(res) {
						if(res.confirm) that.deleteFileAgrees(index);
					}
				})
			},		
			async deleteFileAgrees(index) {
				let {code} = await this.$apis.deleteFileAgree({id:this.model.files[index].id});
				if(code == 200){
					this.model.files.splice(index, 1);
				}
			},
			// 如果打开一个的时候，不需要关闭其他，则无需实现本方法
			openFiles(index) {
				console.log("open",index)
				// 先将正在被操作的swipeAction标记为打开状态，否则由于props的特性限制，
				// 原本为'false'，再次设置为'false'会无效
				this.model.files[index].show = true;
				this.model.files.map((val, idx) => {
					if(index != idx) this.model.files[idx].show = false;
				})
			},
			delFile(id){
				var that = this;
				uni.showModal({
					content:"删除该文件",
					success(res) {
						if(res.confirm) that.deleteFileAgree(id);
					}
				})
			},	
			async deleteFileAgree(id){
				console.log("delFile-id",id);
				let {code} = await this.$apis.deleteFileAgree({id:id});
				if(code == 200){
					this.initPage(this.id);
				}
			},
			delSummary(id){
				var that = this;
				uni.showModal({
					content:"删除该纪要",
					success(res) {
						if(res.confirm) that.deleteNotepadRecord(id);
					}
				})
			},
			async deleteNotepadRecord(id){
				console.log("delSummary-id",id);
				let {code} = await this.$apis.deleteNotepadRecord({id:id});
				if(code == 200){
					this.initPage(this.id);
				}
			},
			async listAddedCourse(){
				let body = {};
				console.log(this.userId);
				if(this.userId != ''){
					body = {
						userId:this.userId,
						userIdentity:0
					}
				}else{
					body = {
						groupId:this.id,
						type:this.type
					}
				}
				let {data} = await this.$apis.listAddedCourse(body);	
				this.courses = data;
			},
			async checkLeader(){
				let result = await this.$apis.checkLeader({teamChatId:this.teamChatId});
				this.isLeader = result.data;	
				if(!this.isLeader && this.userId != ''){
					this.show = false;
				}
			},
			previewImageStr(index,files) { //预览图片
				let imgs = [];
				if(files.indexOf(',') == -1){
					imgs = [files];
				}else{
					imgs = files.split(',');
				}				
				let urls = [];
				for(var i in imgs){
					urls.push(this.$mConfig.baseUrl + imgs[i]);
				}
				console.log(urls);
				uni.previewImage({
					current:index,
					urls: urls
				});
			},
			selectShow(index, flag) {
				this.flagList[index] = !this.flagList[index];
				this.initPage(this.id);
				this.$forceUpdate();
			},
			getImgUrl(url) {
				return this.$mConfig.baseUrl + url;
			},
			scroll(event) {
				//距离每个边界距离
				console.log(event.detail)
			},
			//滚动到底部/右边触发
			scrolltolower() {
				console.log(1111);
			},
			// 滚动到顶部/左边触发
			scrolltoupper() {
				console.log(2222);
			},
			xzjd() { // 显示输入弹出框
				this.userFeedbackHidden = false;
			},
			hideDiv() { // 隐藏输入弹出框
				this.userFeedbackHidden = true;
			},
			async submitFeedback() { // 新增进度
				var _this = this;
				let req = {};
				req.businessId = _this.id;
				req.name = _this.feedbackContent;
				req.type = this.type;
				if(this.userId != '') req['userId'] = this.userId;
				let result = await this.$apis.newProgress(req);
				if (result.code == 200) {
					uni.showToast({
						title: '提交成功',
						icon: 'none'
					});
					this.userFeedbackHidden = true;
					this.initPage(this.id);
				}
				// 提交反馈内容
				console.log(_this.feedbackContent);
			},
			onOpenDoc(file) {
				let url = this.$mConfig.baseUrl + file;
				/* 下载返回临时路径（退出应用失效） */
				this.$refs.lFile.download(url)
				.then(path=>{
					/* 预览 */
					this.$refs.lFile.open(path);
				});
			},			
			/* 保存 */
			onDown(file) {
				let url = this.$mConfig.baseUrl + file;
				this.$refs.lFile.download(url,'local')
				.then(path=>{
					this.localPath = path;
				}); 
			},			
			/* 上传 */
			onUpload(flag) { 
				this.$refs.lFile.upload({
					// #ifdef APP-PLUS
					// nvue页面使用时请查阅nvue获取当前webview的api，当前示例为vue窗口
					currentWebview: this.$mp.page.$getAppWebview(),
					// #endif
					//非真实地址，记得更换,调试时ios有跨域，需要后端开启跨域并且接口地址不要使用http://localhost/
					url: this.$mConfig.baseUrl + "/notepad/saveFile",
					//默认file,上传文件的key
					name: 'file',
					// header: {'Authorization':'token'},
					//...其他参数
					formData: {
						'businessId': this.id,
						'isAgree': flag,
						'type': this.type,
						'userId': this.userId
					},
					header: {
						"X-requested-With": "XMLHttpRequest",
						"ZC-TOKEN": uni.getStorageSync('token')
					}
				});
			},
			upSuccess(res) {
				this.initPage(this.id);
			},
			loadFile(file) {
				uni.downloadFile({
					url: this.$mConfig.baseUrl + file,
					success: function(res) {
						var filePath = res.tempFilePath;
						uni.openDocument({
							filePath: filePath,
							success: function(res) {
								console.log('打开文档成功');
							}
						});
					}
				});
			},
			async initPage(id) {
				let reqBody = {
					id: id,
					type:this.type
				};
				if(this.userId != '') reqBody['userId'] = this.userId;
				let result = await this.$apis.summary(reqBody);
				this.model = result.data;
				
				//获取团队成员
				var users = []
				if (this.model.demand && this.model.demand.integrityDeposit) {
					for (var i in this.model.users) {
						users[i] = this.model.users[i]
						users[i].children = []					
						users[i].show = false
						if (this.model.users[i].blod && this.model.users[i].id == that.$store.state.userInfo.id) {
							that.myblod = this.model.users[i].blod
						}
					}
				} else {
					for (var i in this.model.users) {
						users[i] = this.model.users[i]
						users[i].children = []			
						users[i].show = false
					}
				}
				this.model.users = users
				
				//获取项目成员
				var projects=[],teamId='',teamType='',teams=[];
				if(this.model.projects){
					projects = this.model.projects;
					for (var i in projects) {		
						projects[i] = projects[i]
						var teamChatId = projects[i].teamChatId;
						if(teamChatId){
							this.$set(projects[i], "secondParty",[])
							let params = teamChatId.split('_');
							teamId =  params[1];
							let notepad = this.$mConstDataConfig.notepad;
							for(var k in notepad){
								if(notepad[k].type == params[0]){
									teamType = notepad[k].id
								}
							}
							let reqBody = {id:teamId, type: teamType };
							this.fetchGroupPerson(reqBody,i,projects);
						}
					}		
				}
			},
			async fetchGroupPerson(reqBody,i,projects){
				var {data} = await this.$apis.fetchGroupPerson(reqBody);
				projects[i].secondParty = data;
				this.$nextTick(function(){
					this.model.projects = projects;						
				})
			},
			toChoice(id) {
				if(this.$store.state.userInfo.identityType != 1){
					uni.showToast({
						title:"只有企业才可以添加",
						icon:'none'
					})
					return;
				}
				let param = '';
				if(this.userId) param = "&userId="+this.userId;
				uni.navigateTo({
					url: "../../classroom/choice?type="+this.type+"&id=" + id+param
				})
			},
			toTeamMembers() {
				let param = '';
				if(this.userId != '') param = "?userId="+this.userId;
				uni.navigateTo({
					url: "../../notepad/zhihuiTeam/teamMembers"+param
				})
			},
			toProjectAllocation() {
				let param = '';
				if(this.userId != '') param = "?userId="+this.userId;
				uni.navigateTo({
					url: "../../notepad/zhihuiTeam/projectAllocationDetails"+param
				})
			},
			tohomepage() {
				uni.navigateTo({
					url: "../../homepage/homepage"
				})
			},
			toteamPage() {
				uni.navigateTo({
					url: "../../homepage/teamPage"
				})
			},
			tonewSummary(id) {
				let param = '';
				if(this.userId != '') param = "&userId="+this.userId;
				uni.navigateTo({
					url: "../../notepad/zhihuiTeam/newSummary?&type="+this.type+"&id=" + id+param
				})
			},
			toConfirmation(item) {
				uni.navigateTo({
					url: '../../notepad/zhihuiTeam/confirmation?id='+item.id
				})
			}		
		},

	}
</script>

<style>	page {background-color: #F5F5F9;}</style>
<style scoped lang="scss">
	
	.td {
		padding:0 5rpx;
		color: #ffffff;
		font-size: 24rpx;
		height: 36rpx;
		background: #19C07D;
		border-radius: 6rpx;
		margin-left: 20rpx;
	}
	.container {background-color: #fff;}
	.top {
		.tdmc {
			line-height: 100rpx;
			width: 90%;
			margin-left: 5%;

			text {
				font-size: 30rpx;
				color: #0D1D36;
			}

			.right {
				position: absolute;
				left: 228rpx;
			}

			.jine {
				position: absolute;
				left: 228rpx;
				font-size: 30rpx;
				color: #AB61FF;
			}
		}
	}

	.fgx {
		width: 100%;
		height: 20rpx;
		background-color: #F5F5F9;
	}

	.xmkk {
		width: 118rpx;
		height: 136rpx;
		background-repeat: no-repeat;
		background-size: 100% auto;
		background-position: 0 bottom;

		text {
			color: #888D99;
			font-size: 28rpx;
			margin: 0 auto;
			display: block;
			width: 100rpx;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}
	}

	.xmfp {
		color: #0D1D36;
		font-weight: bold;
	}

	.xmfpxj {
		width: 690rpx;
		// height: 6rpx;
		background: #F5F5F9;
		border-radius: 10rpx;

		.tubiao {
			color: #0D1D36;
			font-size: 30rpx;
		}

		.xhx {
			width: 100%;
			height: 1rpx;
			background-color: #CACEDB;
			margin-top: 20rpx;
		}
	}

	.qylg {
		width: 102rpx;
		height: 118rpx;
		background-size: 100% auto;
		background-position: 0 bottom;
		text-align: center;
		overflow: hidden;
		display: flex;
		justify-content: center;
		align-items: center;
		text {
			color: #888D99;
			font-size: 24rpx;
			line-height: 35rpx;
			padding:0 5rpx;
		}
	}
	.qylg-p {
		width: 102rpx;
		height: 118rpx;
		margin-top:10rpx;
		margin-right:5rpx;
		background-size: 100% auto;
		background-position: 0 bottom;
		text-align: center;
		overflow: hidden;
		display: flex;
		justify-content: center;
		align-items: center;
		text {
			color: #888D99;
			font-size: 24rpx;
			padding:0 5rpx;
		}
	}
	.title {
		display: flex;
		justify-content: space-between;
	}

	.tz {
		width: 68rpx;
		color: #FFFFFF;
		font-size: 24rpx;
		height: 36rpx;
		background: #AB61FF;
		border-radius: 6rpx;
		margin-left: 20rpx;
	}

	.name {
		font-size: 30rpx;
		color: #0D1D36;
		font-weight: bold;
	}

	.explain {
		color: #888D99;
		font-size: 26rpx;
	}

	.fpbl {
		position: absolute;
		left: 500rpx;

		text {
			font-size: 24rpx;
			color: #4B9CFF;
		}

		.fpblsz {
			width: 68rpx;
			height: 36rpx;
			border: 2rpx solid #4B9CFF;
			border-radius: 6rpx;
			margin-left: 10rpx;
		}

		.bfh {
			font-size: 24rpx;
			margin-left: 15rpx;
		}
	}

	.ckqb {
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 26rpx;
		color: #FF8F28;
		margin-top: 30rpx;
	}

	.xhx {
		width: 100%;
		height: 2rpx;
		background-color: #DADFED;
		margin-top: 34rpx;
	}

	.scxy {
		display: flex;
		align-items: center;
		width: 190rpx;
		height: 52rpx;
		border: 2rpx solid #AB61FF;
		border-radius: 26rpx;
		color: #AB61FF;
		font-size: 26rpx;

		image {
			width: 30rpx;
			height: 30rpx;
			margin-top: 5rpx;
			margin-left: 26rpx;
		}
	}

	.tdxy {
		width: 690rpx;
		height: 159rpx;
		background: #F5F5F9;
		border-radius: 20rpx;

		.word {
			display: flex;
			align-items: center;

			image {
				width: 41rpx;
				height: 37rpx;
			}

			text {
				color: #4B9CFF;
				font-size: 30rpx;
				margin-left: 16rpx;
			}
		}
	}

	.scsj {
		color: #0D1D36;
		font-size: 26rpx;
	}

	.sctime {
		display: flex;
		align-items: center;
		color: #888D99;
		font-size: 30rpx;
		margin-left: 20rpx;
	}

	.ty {
		width: 18rpx;
		height: 18rpx;
		background: #888D99;
		border-radius: 50%;
	}

	.xmjz {
		color: #888D99;
		font-size: 30rpx;
		margin-left: 20rpx;
	}

	.xx {
		width: 2rpx;
		height: 2rpx;
		border: 2rpx dashed #888D99;
		opacity: 0.5;
		margin-left: 7rpx;
	}

	.zxjz {
		color: #0D1D36;
		font-size: 30rpx;
		font-weight: bold;
		margin-left: 40rpx;
		margin-top: -100rpx;
	}

	.tp {
		width: 192rpx;
		height: 192rpx;
		border-radius: 10rpx;
		background-color: #F5F5F9;
		margin-left: 30rpx;
		margin-top: 24rpx;
	}

	.tyqk {
		color: #0D1D36;
		font-size: 26rpx;
	}

	.hekuai {
		color: #FFFFFF;
		font-size: 26rpx;
		width: 72rpx;
		height: 32rpx;
		background: #4F5A78;
		border-radius: 4rpx;
		text-align: center;
		line-height: 32rpx;
		margin-left: 22rpx;
	}

	.sd {
		width: 48rpx;
		height: 48rpx;
	}

	.word {
		display: flex;
		align-items: center;

		image {
			width: 41rpx;
			height: 37rpx;
		}

		text {
			color: #4B9CFF;
			font-size: 30rpx;
			margin-left: 16rpx;
		}
	}

	.qymc {
		width: 102rpx;
		height: 118rpx;
		background-repeat: no-repeat;
		background-size: 100% auto;
		background-position: 0 bottom;

		text {
			color: #888D99;
			font-size: 20rpx;
			line-height: 118rpx;
			margin-left: 8rpx;
			display: block;
			width: 94rpx;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}
	}

	.xmlb {
		width: 690rpx;
		// height: 370rpx;
		
		border-radius: 10rpx;
	}

	.hz {
		color: #0D1D36;
		display: block;
		width:200rpx;
	}

	.js {
		color: #888D99;
		position: absolute;
		left: 236rpx;
	}

	.sc {
		display: flex;
		align-items: center;
		width: 136rpx;
		height: 52rpx;
		border: 2rpx solid #AB61FF;
		border-radius: 26rpx;
		color: #AB61FF;
		font-size: 26rpx;

		image {
			width: 30rpx;
			height: 30rpx;
			margin-top: 5rpx;
			margin-left: 26rpx;
		}
	}

	.f-list {

		border-bottom: 2rpx solid #DADFED;

	}

	.file-img {
		width: 102rpx;
		height: 118rpx;
		background-size: 100% auto;
		background-position: 0 bottom;
		margin-left: 28rpx;

		text {
			color: #888D99;
			font-size: 26rpx;
			line-height: 118rpx;
			margin-left: 27rpx;
		}
	}

	.name {
		font-size: 28rpx;
		color: #4C9CFF;
	}

	.tz {
		width: 68rpx;
		color: #FFFFFF;
		font-size: 24rpx;
		height: 36rpx;
		background: #AB61FF;
		border-radius: 6rpx;
		margin-left: 20rpx;
	}

	.xz {
		width: 114rpx;
		height: 50rpx;
		background: #4C9CFF;
		border-radius: 25rpx;
		color: #FFFFFF;
		font-size: 26rpx;
		text-align: center;
		line-height: 50rpx;
		float: right;
	}

	.rq {
		font-size: 28rpx;
		color: #888E9A;
	}

	.wjdx {
		font-size: 28rpx;
		color: #888E9A;
		margin-left: 20rpx;
	}

	.popup_overlay {

		position: fixed;
		top: 0%;
		left: 0%;
		width: 100%;
		height: 100%;
		background-color: black;
		z-index: 1001;
		-moz-opacity: 0.8;
		opacity: .80;
		filter: alpha(opacity=88);
	}

	.popup_content {
		position: fixed;
		top: 50%;
		left: 50%;
		width: 520upx;
		height: 550upx;
		margin-left: -270upx;
		margin-top: -270upx;
		border: 10px solid white;
		background-color: white;
		z-index: 1002;
		overflow: auto;
		border-radius: 20upx;
	}

	.popup_title {
		padding-top: 20upx;
		width: 480upx;
		text-align: center;
		font-size: 32upx;
	}

	.popup_textarea_item {
		padding-top: 5upx;
		height: 240upx;
		width: 440upx;
		background-color: #F1F1F1;
		margin-top: 30upx;
		margin-left: 20upx;
	}

	.popup_textarea {
		width: 410upx;
		font-size: 26upx;
		margin-left: 20upx;
	}

	.popup_button {
		color: white;
		background-color: #4399FC;
		border-radius: 20upx;
	}

	.u-order-title {
		color: #4B9CFF;
		font-size: 30rpx;
	}

	.u-order-time {
		color: #888D99;
	}

	.scroll-view_H {
		white-space: nowrap;

		.scroll-view-item_H {
			display: inline-block;
			width: 100%;
		}

		.uni-bg-red {
			background: red;
		}

		.uni-bg-green {
			background: green;
		}
		.uni-bg-blue {
			background: blue;
		}
	}
	.swiper {height:500rpx;}
</style>
